/**
 * 制作者：九哥
 * 注册员工数据对接
 * 时间：2019-03-06
 * */





/**
 * 引入缓存设置文件 cache.js
 * */
document.write("<script type='text/javascript' src='/h5/js/cache.js'></script>");





//var app_access = 'qSoiKwpWVge4TkaryH6MKvOdceGt7ZMaF20g8H0cnXI';





/**
 * 员工类型选择
 * */
$('.employeeItem').on('click',function(){
    var staffType = this.getAttribute('data-id');
    $('.employeeItem').removeClass('staffClick');
    $(this).addClass('staffClick');
    $('#staffType')[0].value = staffType;
});

/**
 * 员工类型设置
 * */
$('#staffTypeNext').on('click',function(){
    var staffType = $('#staffType').val();
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (staffType==0) { getErrMsg('员工类型未设置！'); return; }
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    //存储到本地
    var dataCache = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:staffType
    };
    cacheSet('userInfo',dataCache);
    if (staffType==1) { //工厂员工信息
        window.location.href = 'staffJobFac.html';
    }
    else if (staffType==2) { //公司员工信息
        window.location.href = 'staffJobCom.html';
    }
    else {
        getErrMsg('未知错误！');
    }
});


/**
 * ------------------------------
 * 员工资料1表单填选
 * ------------------------------
 * */

/**
 * 员工资料1：获取
 * */
function getStaffInfo(){
    //
    MC.UI.muiDtPicker.bind('#staffBirth');
    MC.UI.muiPopPicker.showSexSelect('#staffSex',function(){
        staffInfoChange();
    });

    var userInfo = cacheGet('userInfo'); //获取用户信息
   // var comInfo = cacheGet('staffInfo'); //获取注册缓存资料
  /*  if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }*/

   /* if (comInfo != '') {
        staffInfoLocalStorage()
        return false
    }*/
    
    var data = {
        app_access:app_access//,
    //   token:userInfo.token,
        /* type:userInfo.type,
        cate:userInfo.cate*/
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'staff/show',
        data:data,
        success:function(res){
            //console.log(res); return;
            var i, i2, skillHtml = '', hobbyHtml = '';
            var data = res.data;
          //  $('#skillStr')[0].value = data.skillStr;
       //     $('#hobbyStr')[0].value = data.hobbyStr;
            var skills = data.skills;
            var hobbys = data.hobbys;
            for (i=0;i<skills.length;i++) {
                skillHtml += '<span class="businessItem"><label class="businessValue"><input type="checkbox" class="businessCheck businessSkill" data-text="'+skills[i].name+'" value="'+skills[i].id+'" onclick="setStaffSkill(this.value),staffInfoChange()"';
                if (skills[i].checked==1) { skillHtml += ' checked'; }
                skillHtml += '/> '+skills[i].name+'</label></span>';
            }
            $('#skillCheck').html(skillHtml);
            for (i2=0;i2<hobbys.length;i2++) {
                hobbyHtml += '<span class="businessItem"><label class="businessValue"><input type="checkbox" class="businessCheck businessHobby" data-text="'+hobbys[i2].name+'" value="'+hobbys[i2].id+'" onclick="setStaffHobby(this.value),staffInfoChange()"';
                if (hobbys[i2].checked==1) { hobbyHtml += ' checked'; }
                hobbyHtml += '/> '+hobbys[i2].name+'</label></span>';
            }
            $('#hobbyCheck').html(hobbyHtml);
            
            staffInfoChange()
            //无数据
            if (res.code!=0 || !res.data.realname) {
                console.log(res); return;
            }
            //有数据
            $('#staffName')[0].value = data.realname;
         //   $('#staffSexName')[0].value = data.sexName;
            $('#staffSex')[0].value = data.sex;
         //   $('#staffBirthName')[0].value = data.birth;
            $('#staffBirth')[0].value = data.birth;
            $('#staffEduName')[0].value = data.eduName;
            $('#staffEdu')[0].value = data.edu;
            $('#staffWeight')[0].value = data.weight;
            $('#staffPolity')[0].value = data.polity;
            $('#staffPolityName')[0].value = data.polityName;
            $('#staffOrigin')[0].value = data.origin;
            $('#staffNation')[0].value = data.nation;
            $('#staffMarryName')[0].value = data.marryName;
            $('#staffMarry')[0].value = data.marry;
            $('#idCard')[0].value = data.idcard;
        ///    $('#staffHouse')[0].value = data.house;
          /*  var image = '<img src="'+data.image+'" class="bossFileImgDelete" height="100"/>';
            image += '<input type="hidden" id="staffXxzUrl" value="'+data.image+'"/>';*/
            $('#staffXxzUrl').val(data.image);
            if(data.house=='xuyao'||data.house=='buxuyao'){
                $('#staffHouse').val(data.house);
            }
          //  $('#staffImg').html(image).show();
            $('#staffImages').height(180);
            $('#houseAddress')[0].value = data.houseAddress;
            $('#liveAddress')[0].value = data.liveAddress;
            $('#contactPerson')[0].value = data.contactPerson;
            $('#contactMobile')[0].value = data.contactMobile;
            $('#salary')[0].value = data.salary;

            $('#job')[0].value = data.job;
            $('#job_str')[0].value = data.job_str;
            staffInfoChange();
            MC.View.pic.loadData();
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 员工资料1：设置技能ID
 * */
function setStaffSkill(v){
    var skillStr,skills,index;
    skillStr = $('#skillStr').val();
    if (skillStr=='') {
        $('#skillStr')[0].value = v; return;
    }
    skills = skillStr.split(",");
    index = skills.indexOf(v);
    if (index >= 0) { //有则删除
        skills = $.grep(skills, function(value) {
            return value != v;
        });
        if (skills==[]) { //假如为空
            $('#skillStr')[0].value = ''; return;
        } else { //不为空
            $('#skillStr')[0].value = skills.join(","); return;
        }
    } else { //无则新增
        skills.push(v);
        $('#skillStr')[0].value = skills.join(","); return;
    }
}

/**
 * 员工资料1：设置爱好ID
 * */
function setStaffHobby(v){
    var hobbyStr,hobbys,index;
    hobbyStr = $('#hobbyStr').val();
    if (hobbyStr=='') {
        $('#hobbyStr')[0].value = v; return;
    }
    hobbys = hobbyStr.split(",");
    index = hobbys.indexOf(v);
    if (index >= 0) { //有则删除
        hobbys = $.grep(hobbys, function(value) {
            return value != v;
        });
        if (hobbys==[]) { //假如为空
            $('#hobbyStr')[0].value = ''; return;
        } else { //不为空
            $('#hobbyStr')[0].value = hobbys.join(","); return;
        }
    } else { //无则新增
        hobbys.push(v);
        $('#hobbyStr')[0].value = hobbys.join(","); return;
    }
}

/**
 * 员工资料1：判断是否下一页
 * */
$('#staffInfo1Next').on('click',function() {
    var userInfo = cacheGet('userInfo'); //获取用户信息
    var staffInfo = cacheGet('staffInfo'); //获取用户资料1
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    if (staffInfo=='undefined') {
        getErrMsg('没有选择职位！'); return;
    }
    //获取表单
    var staffName = $('#staffName').val();
    var staffSex = $('#staffSex').val();
    var staffBirth = $('#staffBirth').val();
    var staffEdu = $('#staffEdu').val();
    var staffWeight = $('#staffWeight').val();
    var staffPolity = $('#staffPolity').val();
    var staffOrigin = $('#staffOrigin').val();
    var staffNation = $('#staffNation').val();
    var staffMarry = $('#staffMarry').val();
    var idcard = $('#idCard').val();
    var staffHouse = $('#staffHouse').val();
    var staffXxzUrl = $('#staffXxzUrl').val();
    var houseAddress = $('#houseAddress').val();
    var liveAddress = $('#liveAddress').val();
    var contactPerson = $('#contactPerson').val();
    var contactMobile = $('#contactMobile').val();
    var salary = $('#salary').val();
    var skillStr = $("#skillStr").val();
    var hobbyStr = $("#hobbyStr").val();
    if (staffName=='') { getErrMsg('姓名未填写！'); return; }
    if (staffSex==0) { getErrMsg('性别未选择！'); return; }
    if (staffBirth=='') { getErrMsg('出生未填写！'); return; }
    if (staffEdu==0) { getErrMsg('学历未填选！'); return; }
    if (staffWeight=='') { getErrMsg('体重未填写！'); return; }
    if (staffPolity==0) { getErrMsg('政治面貌未填选！'); return; }
    if (staffOrigin=='') { getErrMsg('籍贯未填写！'); return; }
    if (staffNation=='') { getErrMsg('民族未填写！'); return; }
    if (staffMarry==0) { getErrMsg('婚姻貌未填选！'); return; }
    if (idcard=='') { getErrMsg('身份证号码未填写！'); return; }
    if (staffHouse=='') { getErrMsg('住宿未填写！'); return; }
    if (!staffXxzUrl || staffXxzUrl=='') { getErrMsg('形象照未上传！'); return; }
    if (houseAddress=='') { getErrMsg('户口地址未填写！'); return; }
    if (liveAddress=='') { getErrMsg('现住地址未填写！'); return; }
    if (contactPerson=='') { getErrMsg('紧急联系人未填写！'); return; }
    if (contactMobile=='') { getErrMsg('紧急电话未填写！'); return; }
    if (salary=='') { getErrMsg('期望薪资未填写！'); return; }
    if (skillStr=='') { getErrMsg('技能未填选！'); return; }
    if (hobbyStr=='') { getErrMsg('爱好未填选！'); return; }
    var info = {
        jobType:staffInfo.jobType,
        realname:staffName,
        sex:staffSex,
        birth:staffBirth,
        edu:staffEdu,
        weight:staffWeight,
        polity:staffPolity,
        origin:staffOrigin,
        nation:staffNation,
        marry:staffMarry,
        idcard:idcard,
        house:staffHouse,
        xxz:staffXxzUrl,
        address:houseAddress,
        live:liveAddress,
        person:contactPerson,
        mobile:contactMobile,
        salary:salary,
        skillStr:skillStr,
        hobbyStr:hobbyStr
    };
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate,
        staffInfos:info
    };
    //cacheSet('userInfo',data);
    cacheSet('staffInfo',info); //个人信息
    $.ajax({
        type:'post',
        url:getDomain() + 'staff/modify',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                getErrMsg(res.msg); return;
            }
            staffInfo1Next();
        },
        error:function(){
            getErrMsg('操作失败！'); return;
        }
    });
});

/**
 * 员工资料1：下一页
 * */
function staffInfo1Next(){
    //v：1完成，跳转到首页；2下一页，跳转到下一页
    var h = '';
    h += '<div onclick="window.location.href = \'/h5/index.html\';">完成</div>';
    h += '<div onclick="window.location.href = \'/h5/login/staffInfo2.html\';">下一页</div>';
    h += '<div id="popClose" onclick="popClose(\'staffSex\')">取消</div>';
    $('#popDetail').html(h);
    $('#pop').show();
}

/**
 * 员工资料1：强制判断形象照
 * */
$('#houseAddress').on('click',function(){
    var xxz = $('#staffXxzUrl').val();
    if (xxz=='' || xxz==null) { getErrMsg('形象照没有上传！'); }
});

/**
 * 员工资料1：弹窗性别
 * */
$('#staffSexName').on('click',function(){
    var h = '';
    h += '<div onclick="staffSex(1)">男</div>';
    h += '<div onclick="staffSex(2)">女</div>';
    h += '<div id="popClose" onclick="popClose(\'staffSex\')">取消</div>';
    $('#popDetail').html(h);
    $('#pop').show();
});

/**
 * 员工资料1：弹窗性别选择
 * */
function staffSex(v){
    //var sexType = this.getAttribute("data-id");
    var sexTypeName;
    $('#staffSex')[0].value = v;
    if (v==1) {
        sexTypeName = '男';
    } else {
        sexTypeName = '女';
    }
    $('#staffSexName')[0].value = sexTypeName;
    $('#popDetail').html('');
    $('#pop').hide();
}

/**
 * 员工资料1：弹窗取消
 * */
function popClose(key){
    $('#'+key)[0].value = 0;
    $('#'+key+'Name')[0].value = '';
    $('#popDetail').html('');
    $('#pop').hide();
}


/**
 * 员工资料1：弹窗生日，获取天
 * */
function getBirthDay(v){
    $.ajax({
        type:'post',
        url:getDomain() + 'birthday',
        data:{ app_access:app_access,month:v },
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                getErrMsg(res.msg); return;
            }
            $('#popDay').html(res.data);
        },
        error:function(){
            getErrMsg('操作失败！');
        }
    });
}

/**
 * 员工资料1：弹窗生日选择
 * */
function setBirth(){
    var year = $('#popYear').val();
    var month = $('#popMonth').val();
    var day = $('#popDay').val();
    if (month==0 || day==0) { getErrMsg('出生未填写完善！'); }
    $('#staffBirth')[0].value = year+'-'+month+'-'+day;
  //  $('#staffBirthName')[0].value = year+'-'+month+'-'+day;
    $('#popDetail').html('');
    $('#pop').hide();
}

/**
 * 员工资料1：弹窗学历
 * */
$('#staffEduName').on('click',function(){
    var h = '';
    h += '<div style="height:150px;background:#f8f8f8;overflow:auto;">';
    h += '<div onclick="staffEdu(0)">选择</div>';
    h += '<div onclick="staffEdu(1)">小学</div>';
    h += '<div onclick="staffEdu(2)">初中</div>';
    h += '<div onclick="staffEdu(3)">高中/中专/职高</div>';
    h += '<div onclick="staffEdu(4)">本科</div>';
    h += '<div onclick="staffEdu(5)">研究生</div>';
    h += '<div onclick="staffEdu(6)">博士</div>';
    h += '<div onclick="staffEdu(7)">其他</div>';
    h += '</div>';
    h += '<div id="popClose" onclick="popClose(\'staffEdu\')">取消</div>';
    $('#popDetail').html(h);
    $('#pop').show();
});

/**
 * 员工资料1：弹窗学历选择
 * */
function staffEdu(v){
    var eduArr = new Array('选择','小学',
        '初中','高中/中专/职高',
        '本科','研究生','博士','其他');
    if (v==0) { getErrMsg('您还未选择学历！'); }
    $('#staffEdu')[0].value = v;
    $('#staffEduName')[0].value = eduArr[v];
    $('#popDetail').html('');
    $('#pop').hide();
}

/**
 * 员工资料1：弹窗政治面貌
 * */
$('#staffPolityName').on('click',function(){
    var h = '';
    //h += '<div style="height:150px;background:#f8f8f8;overflow:auto;">';
    h += '<div onclick="staffPolity(0)">选择</div>';
    h += '<div onclick="staffPolity(1)">群众</div>';
    h += '<div onclick="staffPolity(2)">团员</div>';
    h += '<div onclick="staffPolity(3)">党员</div>';
    //h += '</div>';
    h += '<div id="popClose" onclick="popClose(\'staffPolity\')">取消</div>';
    $('#popDetail').html(h);
    $('#pop').show();
});

/**
 * 员工资料1：弹窗政治面貌选择
 * */
function staffPolity(v){
    var polityArr = new Array('选择','群众',
        '团员','党员');
    if (v==0) { getErrMsg('您还未选择学历！'); }
    $('#staffPolity')[0].value = v;
    $('#staffPolityName')[0].value = polityArr[v];
    $('#popDetail').html('');
    $('#pop').hide();
}

/**
 * 员工资料1：弹窗婚姻状态
 * */
$('#staffMarryName').on('click',function(){
    var h = '';
    h += '<div style="height:150px;background:#f8f8f8;overflow:auto;">';
    h += '<div onclick="staffMarry(0)">选择</div>';
    h += '<div onclick="staffMarry(1)">未婚</div>';
    h += '<div onclick="staffMarry(2)">已婚</div>';
    h += '<div onclick="staffMarry(3)">离异</div>';
    h += '<div onclick="staffMarry(4)">丧偶</div>';
    h += '</div>';
    h += '<div id="popClose" onclick="popClose(\'staffMarry\')">取消</div>';
    $('#popDetail').html(h);
    $('#pop').show();
});

/**
 * 员工资料1：弹窗婚姻状态选择
 * */
function staffMarry(v){
    var marryArr = new Array('选择','未婚','已婚','离异','丧偶');
    if (v==0) { getErrMsg('您还未选择婚姻状态！'); }
    $('#staffMarry')[0].value = v;
    $('#staffMarryName')[0].value = marryArr[v];
    $('#popDetail').html('');
    $('#pop').hide();
}

///**
// * 员工资料1：形象照设置
// * */
//function setStaffUpload(){
//    $('#formStaffXxz').attr('action',getDomain()+'upload');
//    //表单数据整体做一个提交
//    $('#staffParam').html(staffFromData());
//    $('#submit').show();
//}

///**
// * 员工资料1：页面数据提交前填充
// * */
//function staffFromData(){
//    var userInfo = cacheGet('userInfo'); //获取用户信息
//    var staffInfo = cacheGet('staffInfo'); //获取用户资料
//    if (userInfo==null || userInfo.token=='undefined') {
//        getErrMsg('没有登录！'); return;
//    }
//    if (staffInfo=='undefined') {
//        getErrMsg('没有选择职位！'); return;
//    }
//    var h = '';
//    h += '<input type="hidden" name="viewJump" value="/h5/login/staffInfo2.html">';
//    h += '<input type="hidden" name="app_access" value="'+app_access+'">';
//    h += '<input type="hidden" name="token" value="'+userInfo.token+'">';
//    h += '<input type="hidden" name="type" value="'+userInfo.type+'">';
//    h += '<input type="hidden" name="cate" value="'+userInfo.cate+'">';
//    h += '<input type="hidden" name="staffName" value="'+$("#staffName").val()+'"/>';
//    h += '<input type="hidden" name="staffJob" value="'+staffInfo.jobType+'"/>';
//    h += '<input type="hidden" name="staffSex" value="'+$("#staffSex").val()+'"/>';
//    h += '<input type="hidden" name="staffBirth" value="'+$("#staffBirth").val()+'"/>';
//    h += '<input type="hidden" name="staffEdu" value="'+$("#staffEdu").val()+'"/>';
//    h += '<input type="hidden" name="staffWeight" value="'+$("#staffWeight").val()+'"/>';
//    h += '<input type="hidden" name="staffPolity" value="'+$("#staffPolity").val()+'"/>';
//    h += '<input type="hidden" name="staffOrigin" value="'+$("#staffOrigin").val()+'"/>';
//    h += '<input type="hidden" name="staffNation" value="'+$("#staffNation").val()+'"/>';
//    h += '<input type="hidden" name="staffMarry" value="'+$("#staffMarry").val()+'"/>';
//    h += '<input type="hidden" name="idCard" value="'+$("#idCard").val()+'"/>';
//    h += '<input type="hidden" name="staffHouse" value="'+$("#staffHouse").val()+'"/>';
//    return h;
//}

/**
 * ------------------------------
 * 员工资料1表单填选
 * ------------------------------
 * */


/**
 * ------------------------------
 * 员工资料2表单填选
 * ------------------------------
 * */

/**
 * 员工资料2，获取
 * */
function getStaffInfo2(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    var staffOption = cacheGet('staffOption'); //获取用户可选资料
    //console.log(staffOption); return;
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    var business = 0, skill = 0;
    var i,i2,i3;
    //if (staffOption=='undefined') {
        $.ajax({
            type:'post',
            url:getDomain() + 'staff/show2',
            data:data,
            success:function(res) {
                //console.log(res); return;
                if (res.code != 0) {
                    getRadioList(business,skill);
                    //console.log(res);
                    return;
                }
                console.log(res.data);
                //var eduBgs = res.data.eduBgs;
                //var workHistorys = res.data.workHistorys;
                //var familys = res.data.familys;
                //var comments = res.data.comments;
                for (i=1;i<=res.data.eduBgCount;i++) {
                    $('#eduBgStart0'+i)[0].value = res.data.eduBgStart[i];
                    $('#eduBgEnd0'+i)[0].value = res.data.eduBgEnd[i];
                    $('#eduBgSchool0'+i)[0].value = res.data.eduBgSchool[i];
                    $('#eduBgMajor0'+i)[0].value = res.data.eduBgMajor[i];
                    $('#eduBgAward0'+i)[0].value = res.data.eduBgAward[i];
                }
                for (i2=1;i2<=res.data.workCount;i2++) {
                    $('#workStart0'+i2)[0].value = res.data.workStart[i2];
                    $('#workEnd0'+i2)[0].value = res.data.workEnd[i2];
                    $('#workComName0'+i2)[0].value = res.data.workComName[i2];
                    $('#workJob0'+i2)[0].value = res.data.workJob[i2];
                    $('#workLeave0'+i2)[0].value = res.data.workLeave[i2];
                }
                for (i3=1;i3<=res.data.familyCount;i3++) {
                    $('#familyName0'+i3)[0].value = res.data.familyName[i3];
                    $('#familyCall0'+i3)[0].value = res.data.familyCall[i3];
                    $('#familyCom0'+i3)[0].value = res.data.familyCom[i3];
                    $('#familyContact0'+i3)[0].value = res.data.familyContact[i3];
                }
                //工厂、公司求职意向
                if (userInfo.cate==2) {
                    $('#comFeature')[0].value = res.data.comFeature;
                    $('#comSkill')[0].value = res.data.comSkill;
                    $('#comHobby')[0].value = res.data.comHobby;
                    $('#comExpect')[0].value = res.data.comExpect;
                    $('#businessRadioInput')[0].value = res.data.businessRadio;
                    $('#skillRadioInput')[0].value = res.data.skillRadio;
                    getRadioList(res.data.businessRadio,res.data.skillRadio);
                }
            },
            error:function(){
                getErrMsg('操作失败！');
            }
        });
    //    return;
    //}
    ////本地读取数据
    //for (i=1;i<=staffOption.eduBgCount;i++) {
    //    $('#eduBgStart0'+i)[0].value = staffOption.eduBgStart[i];
    //    $('#eduBgEnd0'+i)[0].value = staffOption.eduBgEnd[i];
    //    $('#eduBgSchool0'+i)[0].value = staffOption.eduBgSchool[i];
    //    $('#eduBgMajor0'+i)[0].value = staffOption.eduBgMajor[i];
    //    $('#eduBgAward0'+i)[0].value = staffOption.eduBgAward[i];
    //}
    //for (i2=1;i2<=staffOption.workCount;i2++) {
    //    $('#workStart0'+i2)[0].value = staffOption.workStart[i2];
    //    $('#workEnd0'+i2)[0].value = staffOption.workEnd[i2];
    //    $('#workComName0'+i2)[0].value = staffOption.workComName[i2];
    //    $('#workJob0'+i2)[0].value = staffOption.workJob[i2];
    //    $('#workLeave0'+i2)[0].value = staffOption.workLeave[i2];
    //}
    //for (i3=1;i3<=staffOption.familyCount;i3++) {
    //    $('#familyName0'+i3)[0].value = staffOption.familyName[i3];
    //    $('#familyCall0'+i3)[0].value = staffOption.familyCall[i3];
    //    $('#familyCom0'+i3)[0].value = staffOption.familyCom[i3];
    //    $('#familyContact0'+i3)[0].value = staffOption.familyContact[i3];
    //}
    ////工厂、公司求职意向
    //$('#comFeature')[0].value = staffOption.comFeature;
    //$('#comSkill')[0].value = staffOption.comSkill;
    //$('#comHobby')[0].value = staffOption.comHobby;
    //$('#comExpect')[0].value = staffOption.comExpect;
    //$('#businessRadioInput')[0].value = staffOption.businessRadioInput;
    //$('#skillRadioInput')[0].value = staffOption.skillRadioInput;
    //getRadioList(staffOption.businessRadioInput,staffOption.skillRadioInput);
    //return;
}

/**
 * 员工资料2选项
 * */
function getRadioList(business,skill){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'staff/combyradio',
        data:data,
        success:function(res) {
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            var i, i2, h = '', h2 = '';
            for (i=0;i<res.data.jobTypes.length;i++) {
                h += '<span class="businessItem">';
                h += '<label class="businessValue" onclick="setBusinessRadio('+res.data.jobTypes[i].id+')">';
                h += '<input name="businessTypeCompanyInfo2" type="radio" class="businessCheck"';
                if (business==res.data.jobTypes[i].id) { h += ' checked'; }
                h += '/>';
                h += res.data.jobTypes[i].name;
                h += '</label>';
                h += '</span>';
            }
            for (i2=0;i2<res.data.skills.length;i2++) {
                h2 += '<span class="businessItem">';
                h2 += '<label class="businessValue" onclick="setSkillRadio('+res.data.skills[i2].id+')">';
                h2 += '<input name="TechnicalGradeCompanyInfo2" type="radio" class="businessCheck"';
                if (skill==res.data.skills[i2].id) { h2 += ' checked'; }
                h2 += '/>';
                h2 += res.data.skills[i2].name;
                h2 += '</label>';
                h2 += '</span>';
            }
            $('#businessRadio').html(h);
            $('#skillRadio').html(h2);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 员工资料2，公司业务类型设置
 * */
function setBusinessRadio(v){
    $('#businessRadioInput')[0].value = v;
}

/**
 * 员工资料2，技术等级
 * */
function setSkillRadio(v){
    $('#skillRadioInput')[0].value = v;
}
// 时间选择
var choseDate = '<script>'+
                '$(".regInput").datepicker({'+
                        'dateFormat : "yy-mm-dd",'+
                        'dayNamesMin : [ "一", "二", "三", "四", "五", "六", "日" ],'+
                        'monthNamesShort : ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],'+
                        'changeMonth : true,'+
                        'changeYear : true,'+
                        'firstDay : 0,'+
                        'prevText : "上月",'+
                        'nextText : "下月"'+
                    '})'+
            '</script>'

/**
 * 员工资料2，更多教育背景
 * */
function addEduBg(){
    var eduBgCount = $('#eduBgCount').val();
    if (eduBgCount==3) { getErrMsg('教育背景已达上限！'); return; }
    eduCountNew = eduBgCount * 1 + 1;
    var dom = '';
    dom +=	'<div isVisiableEdu="1" class="eduBgOut'+eduCountNew+'">';
    dom +=		'<div class="companyInfoSpace"></div>';
    dom +=		'<div class="closeImgPanel">';
    dom +=			'<img src="../images/cancel.png" onclick="closeEdu('+eduCountNew+')">';
    dom +=		'</div>';
    dom +=		'<div class="modelPanel">';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请选择起始日期" class="regCode regInput" readonly id="eduBgStart0'+eduCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请选择截止日期" class="regCode regInput" readonly id="eduBgEnd0'+eduCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入毕业院校" class="regCode" id="eduBgSchool0'+eduCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入专业" class="regCode" id="eduBgMajor0'+eduCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<textarea class="factoryIntro" placeholder="所获奖项" id="eduBgAward0'+eduCountNew+'"></textarea>';
    dom +=			'</div>';
    dom +=		'</div>';
    dom +=	'</div>';
    $('#IemployeeEduListCompany').append(dom+choseDate);
    $('#eduBgCount')[0].value = eduCountNew;
}

/**
 * 员工资料2，教育背景删除
 * */
function closeEdu(v){
    $('.eduBgOut'+v).html('');
    var eduCount = $('#eduCount').val();
    $('#eduCount')[0].value = eduCount * 1 - 1;
}

/**
 * 员工资料2，更多工作经历
 * */
function addWork(){
    var workCount = $('#workCount').val();
    if (workCount==3) { getErrMsg('工作经历已达上限！'); return; }
    workCountNew = workCount * 1 + 1;
    var dom = '';
    dom +=	'<div isVisiableJob="1" class="workOut'+workCountNew+'">';
    dom +=		'<div class="companyInfoSpace"></div>';
    dom +=		'<div class="closeImgPanel">';
    dom +=			'<img src="../images/cancel.png" onclick="closeWork('+workCountNew+')">';
    dom +=		'</div>';
    dom +=		'<div class="modelPanel">';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请选择起始日期" class="regCode regInput" readonly id="workStart0'+workCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请选择截止日期" class="regCode regInput" readonly id="workEnd0'+workCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入公司名称" class="regCode" id="workComName0'+workCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入职位" class="regCode" id="workJob0'+workCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="businessTitle">离职原因：</div>';
    dom +=			'<div class="factoryIntroDiv">';
    dom +=				'<textarea class="factoryIntro" id="workLeave0'+workCountNew+'"></textarea>';
    dom +=			'</div>';
    dom +=		'</div>';
    dom +=	'</div>';
    $('#IemployeeJobListCompany').append(dom);
    $('#workCount')[0].value = workCountNew;
}

/**
 * 员工资料2，工作经历删除
 * */
function closeWork(v){
    $('.workOut'+v).html('');
    var workCount = $('#workCount').val();
    $('#workCount')[0].value = workCount * 1 - 1;
}

/**
 * 员工资料2，更多工作经历
 * */
function addFamily(){
    var familyCount = $('#familyCount').val();
    if (familyCount==3) { getErrMsg('工作经历已达上限！'); return; }
    familyCountNew = familyCount * 1 + 1;
    var dom = '';
    dom +=	'<div isVisiableFamily="1" class="familyOut'+familyCountNew+'">';
    dom +=		'<div class="companyInfoSpace"></div>';
    dom +=		'<div class="closeImgPanel">';
    dom +=			'<img src="../images/cancel.png" onclick="closeFamily('+familyCountNew+')">';
    dom +=		'</div>';
    dom +=		'<div class="modelPanel">';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入姓名" class="regCode" id="familyName0'+familyCountNew+'">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入称谓" class="regCode">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入工作单位" class="regCode">';
    dom +=			'</div>';
    dom +=			'<div class="bossInfoDiv">';
    dom +=				'<input type="text" placeholder="请输入联系电话" class="regCode">';
    dom +=			'</div>';
    dom +=		'</div>';
    dom +=	'</div>';
    $('#IemployeeFamilyListCompany').append(dom);
    $('#familyCount')[0].value = familyCountNew;
}

/**
 * 员工资料2，家庭成员删除
 * */
function closeFamily(v){
    $('.familyOut'+v).html('');
    var familyCount = $('#familyCount').val();
    $('#familyCount')[0].value = familyCount * 1 - 1;
}

/**
 * 员工资料2，提交表单
 * */
$('#staffInfo2Next').on('click',function(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    if (userInfo.cate!=1 && userInfo.cate!=2) {
        getErrMsg('没有选择员工类型！'); return;
    }
    //获取表单
    var i, i2, i3, eduBgStart = [], eduBgEnd = [],
        eduBgSchool = [], eduBgMajor = [], eduBgAward = [],
        workStart = [], workEnd = [], workComName = [],
        workJob = [], workLeave = [], familyName = [],
        familyCall = [], familyCom = [], familyContact = [],
        comFeature, comSkill, comHobby, comExpect,
        businessRadioInput, skillRadioInput;
    var eduBgCount = $('#eduBgCount').val();
    var workCount = $('#workCount').val();
    var familyCount = $('#familyCount').val();
    for (i=1;i<=eduBgCount;i++) {
        eduBgStart[i] = $('#eduBgStart0'+i).val();
        eduBgEnd[i] = $('#eduBgEnd0'+i).val();
        eduBgSchool[i] = $('#eduBgSchool0'+i).val();
        eduBgMajor[i] = $('#eduBgMajor0'+i).val();
        eduBgAward[i] = $('#eduBgAward0'+i).val();
    }
    for (i2=1;i2<=workCount;i2++) {
        workStart[i2] = $('#workStart0'+i2).val();
        workEnd[i2] = $('#workEnd0'+i2).val();
        workComName[i2] = $('#workComName0'+i2).val();
        workJob[i2] = $('#workJob0'+i2).val();
        workLeave[i2] = $('#workLeave0'+i2).val();
    }
    for (i3=1;i3<=familyCount;i3++) {
        familyName[i3] = $('#familyName0'+i3).val();
        familyCall[i3] = $('#familyCall0'+i3).val();
        familyCom[i3] = $('#familyCom0'+i3).val();
        familyContact[i3] = $('#familyContact0'+i3).val();
    }
    //eduBgStart.splice(0,1);
    comFeature = $('#comFeature').val();
    comSkill = $('#comSkill').val();
    comHobby = $('#comHobby').val();
    comExpect = $('#comExpect').val();
    businessRadioInput = $('#businessRadioInput').val();
    skillRadioInput = $('#skillRadioInput').val();
    var infos = {
        eduBgCount:eduBgCount,
        workCount:workCount,
        familyCount:familyCount,
        //教育背景
        eduBgStart:eduBgStart,
        eduBgEnd:eduBgEnd,
        eduBgSchool:eduBgSchool,
        eduBgMajor:eduBgMajor,
        eduBgAward:eduBgAward,
        //工作经历
        workStart:workStart,
        workEnd:workEnd,
        workComName:workComName,
        workJob:workJob,
        workLeave:workLeave,
        //家庭成员
        familyName:familyName,
        familyCall:familyCall,
        familyCom:familyCom,
        familyContact:familyContact,
        //其他
        comFeature:comFeature,
        comSkill:comSkill,
        comHobby:comHobby,
        comExpect:comExpect,
        businessRadioInput:businessRadioInput,
        skillRadioInput:skillRadioInput
    };
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate,
        staffOptions:infos
    };
    //cacheSet('staffOption',infos); //缓存用户可选信息
    $.ajax({
        type:'post',
        url:getDomain() + 'staff/option',
        data:data,
        success:function(res) {
            //console.log(res); return;
            if (res.code!=0) {
                getErrMsg(res.msg); return;
            }
            if (userInfo.cate==1) {
                window.location.href = 'staffFacWill.html';
            } else {
                window.location.href = 'staffComWill.html';
            }
        },
        error:function(){
            getErrMsg('操作失败！'); return;
        }
    });
});

/**
 * ------------------------------
 * 员工资料2表单填选
 * ------------------------------
 * */


/**
 * ------------------------------
 * 员工公司求职意向
 * ------------------------------
 * */

/**
 * 员工公司求职意向，获取
 * */
function getComWills() {
    var userInfo = cacheGet('userInfo'); //获取用户信息
    var comWills = cacheGet('staffComWills'); //获取用户公司求职意向
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    //没有则请求
    if (comWills=='undefined' || comWills==null) {
        $.ajax({
            type:'post',
            url:getDomain() + 'staff/com-will',
            data:data,
            success:function(res){
                //console.log(res); return;
                if (res.code!=0) {
                    console.log(res); return;
                }
                $('#address')[0].value = res.data.address;
                $('#jobModule')[0].value = res.data.jobModule;
                $('#job')[0].value = res.data.job;
                $('#salary')[0].value = res.data.salary;
                $('#workType')[0].value = res.data.workType;
                $('#industry')[0].value = res.data.industry;
                $('#jobTime')[0].value = res.data.jobTime;
                var tags, i, tagHtml = '';
                tags = res.data.tags;
                for (i=0;i<tags.length;i++) {
                    tagHtml += '<style>.tags{max-width:50px;border:1px solid #cccccc;text-align:center;}</style>';
                    tagHtml += '<input type="text" class="regCode tags" readonly value="'+tags[i]+'" id="tagInput'+tags[i]+'"/>&nbsp;';
                }
                $('#tags').html(tagHtml);
            },
            error:function(){
                console.log('操作失败！'); return;
            }
        });
        return;
    }
    //有则加载本地
    //console.log(comWills);
    $('#address')[0].value = comWills.address;
    $('#jobModule')[0].value = comWills.jobModule;
    $('#job')[0].value = comWills.job;
    $('#salary')[0].value = comWills.salary;
    $('#workType')[0].value = comWills.workType;
    $('#industry')[0].value = comWills.industry;
    $('#jobTime')[0].value = comWills.jobTime;
    var tags,tagStr, i, tagHtml = '';
    tagStr = comWills.tags;
    tags = tagStr.split("||");
    //console.log(tagStr,tags);
    for (i=0;i<tags.length;i++) {
        tagHtml += '<style>.tags{max-width:50px;border:1px solid #cccccc;text-align:center;}</style>';
        tagHtml += '<input type="text" class="regCode tags" readonly value="'+tags[i]+'" id="tagInput'+tags[i]+'"/>&nbsp;';
    }
    $('#tags').html(tagHtml);
}

/**
 * 员工公司求职意向，省市区
 * */
function getProvice(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        pid:0
    };
    var h = '';
    h += '<div style="text-align:center">';
    h += '<select id="provice" onchange="getRegion(this.value,2)"> <option value="">选择省</option> </select>';
    h += '<select id="city" onchange="getRegion(this.value,3)"> <option value="">选择市</option> </select>';
    h += '<select id="region" onchange="getRegion(this.value,4)"> <option value="">选择区</option> </select>';
    h += '</div> <div id="popClose"><a href="javascript:;" style="color:#0088cc;" onclick="setProviceSure()">确定</a><a href="javascript:;" onclick="setProviceClose()">取消</a></div>';
    $('#popDetail').html(h);
    $('#pop').show();
    //获取省
    getRegion(100000,1); //省ID，级别
}

/**
 * 员工公司求职意向，省市区设置
 * */
function getRegion(pid,level){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        pid:pid
    };
    if (level==4) {//确定区
        $('#regionId')[0].value = pid;
        $('#address')[0].value = $('#address').val() + $('#region'+pid).val();
        return;
    }
    $.ajax({
        type:'post',
        url:getDomain() + 'region',
        data:data,
        success:function(res){
            //console.log(res); return;
             if (res.code!=0) {
                 console.log(res); return;
             }
            var i, h = '', spanHtml = '', address;
            if (level==1) { //省列表
                h += '<option value="0">省</option>';
                for (i=0;i<res.data.length;i++) {
                    h += '<option value="'+res.data[i].id+'">';
                    h += res.data[i].name;
                    h += '</option>';
                    spanHtml += '<input type="hidden" id="provice'+res.data[i].id+'" value="'+res.data[i].name+'"/>';
                }
                $('#provice').html(h);
                $('#proviceHtml').html(spanHtml);
                $('#city').html('<option value="0">选择市</option>');
                $('#region').html('<option value="0">选择区</option>');
                $('#cityHtml').html('');
                $('#regionHtml').html('');
                $('#proviceId')[0].value = 0;
                $('#cityId')[0].value = 0;
                $('#regionId')[0].value = 0;
            }
            else if (level==2) { //确定省，市列表
                h += '<option value="0">市</option>';
                for (i=0;i<res.data.length;i++) {
                    h += '<option value="'+res.data[i].id+'">';
                    h += res.data[i].name;
                    h += '</option>';
                    spanHtml += '<input type="hidden" id="city'+res.data[i].id+'" value="'+res.data[i].name+'"/>';
                }
                $('#city').html(h);
                $('#cityHtml').html(spanHtml);
                $('#region').html('<option value="0">选择区</option>');
                $('#regionHtml').html('');
                $('#proviceId')[0].value = pid;
                $('#cityId')[0].value = 0;
                $('#regionId')[0].value = 0;
                address = $('#address').val();
                $('#address')[0].value = address + $('#provice'+pid).val() + '，';
            }
            else if (level==3) { //确定市，区列表
                h += '<option value="0">区</option>';
                for (i=0;i<res.data.length;i++) {
                    h += '<option value="'+res.data[i].id+'">';
                    h += res.data[i].name;
                    h += '</option>';
                    spanHtml += '<input type="hidden" id="region'+res.data[i].id+'" value="'+res.data[i].name+'"/>';
                }
                $('#region').html(h);
                $('#regionHtml').html(spanHtml);
                $('#cityId')[0].value = pid;
                $('#regionId')[0].value = 0;
                address = $('#address').val();
                $('#address')[0].value = address + $('#city'+pid).val() + '，';
            }
        },
        error:function(){
            getErrMsg('操作失败！'); return;
        }
    });
}

/**
 * 员工公司求职意向，省市区确定
 * */
function setProviceSure(){
    $('#popDetail').html('');
    $('#pop').hide();
}

/**
 * 员工公司求职意向，省市区取消
 * */
function setProviceClose(){
    //$('#address')[0].value = '';
    //$('#proviceHtml').html('');
    //$('#cityHtml').html('');
    //$('#regionHtml').html('');
    //$('#proviceId')[0].value = 0;
    //$('#cityId')[0].value = 0;
    //$('#regionId')[0].value = 0;
    $('#popDetail').html('');
    $('#pop').hide();
}

/**
 * 员工公司求职意向，个人标签
 * */
function getTags(){
    var tagCount = $('#tagCount').val();
    if (tagCount==3) { getErrMsg('已达上线！'); return; }
    var h = '', h2 = '';
    h += '<div style="text-align:center">';
    h += '<input type="text" id="addTag" placeholder="输入标签" style="padding:5px;border:0;" max-length="5"/>';
    h += '</div> <div id="popClose"><a href="javascript:;" style="color:#0088cc;" onclick="setTagAdd($(\'#addTag\').val());">确定</a><a href="javascript:;" onclick="setTagClose()">取消</a></div>';
    $('#popDetail').html(h);
    $('#pop').show();
}

/**
 * 员工公司求职意向，个人标签
 * */
function setTagAdd(v){
    var tagCount, tagStr, h = '';
    if (v=='') { getErrMsg('没有输入！'); return; }
    tagCount = $('#tagCount').val();
    tagCountNew = tagCount * 1 + 1;
    h += '<style>.tags{max-width:50px;border:1px solid #cccccc;text-align:center;}</style>';
    //h += '<span onclick="setTagDel('+tagCountNew+')" id="tagSpan'+tagCountNew+'"><input type="text" class="regCode tags" readonly value="'+v+'" id="tagInput'+tagCountNew+'"/><span>&nbsp;';
    h += '<input type="text" class="regCode tags" readonly value="'+v+'" id="tagInput'+tagCountNew+'"/>&nbsp;';
    if (tagCount==0) { $('#tags').html(''); }
    $('#tags').append(h);
    $('#tagCount')[0].value = tagCountNew;
    $('#popDetail').html('');
    $('#pop').hide();
    //设置隐藏域
    tagStr = $('#tagStr').val();
    if (tagStr=='') {
        $('#tagStr')[0].value =  v;
    } else {
        $('#tagStr')[0].value =  tagStr+ '||' + v;
    }
}

/**
 * 员工公司求职意向，标签取消
 * */
function setTagClose(){
    $('#popDetail').html('');
    $('#pop').hide();
}

///**
// * 员工公司求职意向，标签删除
// * */
//function setTagDel(v){
//    var tagCount,i,tagInput,tagStr = '';
//    tagCount = $('#tagCount').val();
//    $('#tag'+v).html(''); //清除对应标签
//    //更新隐藏域标签
//    for (i=1;i<=tagCount;i++) {
//        tagInput = $('#tagInput'+tagCount).val();
//        if (tagInput!='undefined') {
//            if (tagStr!='') {
//                tagStr = tagInput;
//            } else {
//                tagStr = tagStr + '||' + tagInput;
//            }
//        }
//    }
//    //console.log(tagStr);
//    //tagCountNew = tagCount * 1 - 1;
//    //$('#tagCount')[0].value = tagCountNew;
//}

/**
 * 日期选择器
 * */
$('#jobTime').each(
    function() {
        $(this).datepicker({
                dateFormat : "yy-mm-dd",
                dayNamesMin : [ "一", "二", "三", "四", "五", "六", "日" ],
                monthNamesShort : ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                changeMonth : true,
                changeYear : true,
                firstDay : 0,
                prevText : '上月',
                nextText : '下月'
            });
    }
);

/**
 * 员工公司求职意向
 * */
$('#staffComWillNext').on('click',function(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var address = $('#address').val();
    var jobModule = $('#jobModule').val();
    var job = $('#job').val();
    var salary = $('#salary').val();
    var workType = $('#workType').val();
    var industry = $('#industry').val();
    var jobTime = $('#jobTime').val();
    var tagStr = $('#tagStr').val();
    //var tags = tagStr.split("||");
    var comWills = {
        address:address,
        jobModule:jobModule,
        job:job,
        salary:salary,
        workType:workType,
        industry:industry,
        jobTime:jobTime,
        tags:tagStr
    };
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate,
        comWills:comWills
    };
    //console.log(data); return;
    cacheSet('staffComWills',comWills); //员工公司求职意向
    $.ajax({
        type:'post',
        url:getDomain() + 'staff/set-com-will',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                getErrMsg(res.msg); return;
            }
            window.location.href = 'staffFile.html';
        },
        error:function(){
            getErrMsg('操作失败！'); return;
        }
    });
});

/**
 * ------------------------------
 * 员工公司求职意向
 * ------------------------------
 * */





/**
 * ------------------------------
 * 员工工厂求职意向
 * ------------------------------
 * */

/**
 * 员工工厂求职意向，获取
 * */
function getFacWill(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    var facWills = cacheGet('facWills'); //获取用户工厂求职意向
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    $('form').attr('action','/api/member/staff/set-fac-will');
    //$('.viewJump')[0].value = '/h5/login/staffFile.html';
    $('.viewJump')[0].value = '/h5/login/staffList.html';
    $('.app_access')[0].value = app_access;
    $('.token')[0].value = userInfo.token;
    $('.type')[0].value = userInfo.type;
    $('.cate')[0].value = userInfo.cate;
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    //无则请求
    if (facWills=='undefined' || facWills==null) {
        $.ajax({
            type:'post',
            url:getDomain() + 'staff/fac-will',
            data:data,
            success:function(res){
                //console.log(res); return;
                if (res.code!=0) {
                    getFabricTypeList(0);
                    getTechLevelList(0);
                    getSkillList(0);
                    console.log(res); return;
                }
                getFabricTypeList(res.data.fabrics);
                getTechLevelList(res.data.tech);
                getSkillList(res.data.skills);
            },
            error:function(){
                console.log('操作失败！'); return;
            }
        });
        return;
    }
    //有则加载本地缓存
}

/**
 * 面料种类
 * */
function getFabricTypeList(v){
    var i, types, h = '';
    types = new Array('','牛仔','单面尼','双面尼',
        '羽绒服','针织','梭织','真丝','雪纺');
    for (i=1;i<=types.length-1;i++) {
        h += '<span class="businessItem">';
        h +=    '<label class="businessValue">';
        h +=        '<input type="checkbox" class="businessCheck" name="fabricTypes[]" value="'+i+'"';
        for (var i2=0;i2<= v.length;i2++) {
            if (i==v[i2]) { h += ' checked'; }
        }
        h +=        '/>';
        h +=        types[i];
        h +=    '</label>';
        h += '</span>';
    }
    $('#fabricTypeCheck').html(h);
}

/**
 * 技术等级
 * */
function getTechLevelList(v){
    var i, techs, h = '';
    techs = new Array('','学徒','工作1-2年','工作3-5年',
        '工作6-10年','10年以上');
    for (i=1;i<=techs.length-1;i++) {
        h += '<span class="businessItem">';
        h +=    '<label class="businessValue">';
        h +=        '<input type="radio" class="businessCheck" name="techLevel" value="'+i+'"';
        for (var i2=0;i2<= v.length;i2++) {
            if (i==v[i2]) { h += ' checked'; }
        }
        h +=        '/>';
        h +=        techs[i];
        h +=    '</label>';
        h += '</span>';
    }
    $('#techLevelRadio').html(h);
}

/**
 * 擅长技能
 * */
function getSkillList(v){
    var i, skills, h = '';
    skills = new Array('','拼缝','做领子','上领子',
        '开口袋','大烫','模板车','双针车','套里布',
        '西装','西裤','裤子','大衣','装拉链','小烫','压线','夹克');
    for (i=1;i<=skills.length-1;i++) {
        h += '<span class="businessItem">';
        h +=    '<label class="businessValue">';
        h +=        '<input type="checkbox" class="businessCheck" name="skills[]" value="'+i+'"';
        for (var i2=0;i2<= v.length;i2++) {
            if (i==v[i2]) { h += ' checked'; }
        }
        h +=        '/>';
        h +=        skills[i];
        h +=    '</label>';
        h += '</span>';
    }
    $('#skillCheck').html(h);
}

///**
// * 员工工厂求职意向提交，下一步
// * */
//$('#staffFacWillNext').on('click',function(){
//    var userInfo = cacheGet('userInfo'); //获取用户信息
//    if (userInfo==null || userInfo.token=='undefined') {
//        getErrMsg('没有登录！'); return;
//    }
//});

/**
 * ------------------------------
 * 员工工厂求职意向
 * ------------------------------
 * */





/**
 * ------------------------------
 * 员工公司认证
 * ------------------------------
 * */

/**
 * 员工公司认证，获取
 * */
function getComFiles(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'staff/com-file',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            console.log(res.data);
            var data=res.data;
            $('#self').val(data.self);
            $('#idcard').val(data.idcard);
            $('#byz').val(data.byz);

            $('#award').val(data.award);
            $('#marry').val(data.marry);
            $('#drive').val(data.drive);
            MC.View.pic.loadData();
            /**'self': $('#self').val(),
             'idcard': $('#idcard').val(),
             'byz': $('#byz').val(),
             'award': $('#award').val(),
             'marry': $('#marry').val(),
             'drive': $('#drive').val(),*/
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * ------------------------------
 * 员工公司认证
 * ------------------------------
 * */





/**
 * ------------------------------
 * 员工职位
 * ------------------------------
 * */

/**
 * 获取职位列表
 * */
function getJoblist(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    var staffInfo = cacheGet('staffInfo'); //获取用户资料
    if (userInfo==null || userInfo.token=='undefined') {
        getErrMsg('没有登录！'); return;
    }
    var jobType = 0;
    if (staffInfo && staffInfo.jobType) {
        jobType = staffInfo.jobType;
    }
    //console.log(staffInfo.jobType)
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'staff/joblist',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            console.log(res.data); return;

        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 获取职位，设置
 * */
function setJobRadio(id){
    var staffInfo = cacheGet('staffInfo'); //员工信息1
    if (staffInfo && staffInfo.jobType) {
        staffInfo.jobType = id;
    } else {
        staffInfo = { jobType:id };
    }
    //console.log(staffInfo); return;
    cacheSet('staffInfo',staffInfo);
    $('#jobComId')[0].value = id;
    //window.location.href = '';
    getErrMsg('设置成功！'); return;
}

/**
 * ------------------------------
 * 员工职位
 * ------------------------------
 * */





/**
 * 地址前缀
 * */
function getDomain(){
    return '/api/member/';
}


///**
// * -------------------------
// * 本地缓存
// * -------------------------
// * */
//
///**
// * 本地缓存，获取
// * */
//function cacheGet(key){
//    //return localStorage.getItem(key);
//    return JSON.parse(localStorage.getItem(key));
//}
//
///**
// * 本地缓存，新增
// * */
//function cacheSet(key,val){
//    //var cache = cacheGet(key);
//    //if (cache!='undefined') { getErrMsg('已存在！'); }
//    //localStorage.setItem(key,val);
//    //为防止没有设置值获取后出现object类型 转化出错,提前进行设置空字符串
//    localStorage.setItem(key, "");
//    localStorage.setItem(key, JSON.stringify(val));
//}
//
///**
// * 本地缓存，删除
// * */
//function cacheDel(key){
//    localStorage.remove(key);
//}
//
///**
// * 本地缓存，删除
// * */
//function cacheClear(){
//    localStorage.clear();
//}





/**
 * 错误提示框
 * */
function getErrMsg(msg){
    var h = '';
    h += '<span>'+msg+'</span>';
    h += '<script>setTimeout("setErrClose()",1000*3); function setErrClose(){ $("#errMsg").html("").hide(); }</script>';
    $('#errMsg').html(h).show();
}